﻿using System;

namespace HelixSoftware.Azure.Data
{
    public abstract class DataObjectService<T> : IDataObjectService<T> where T : DataObject
    {
        public virtual T CreateNew()
        {
            throw new NotImplementedException();
        }

        public virtual object Save(T obj)
        {
            switch (obj.SaveAction)
            {
                case SaveAction.Insert:
                    return this.Insert(obj);
                case SaveAction.Update:
                    return this.Update(obj);
                case SaveAction.Delete:
                    return this.Delete(obj);
                default:
                    throw new InvalidOperationException("obj does not need to be saved.");
            }
        }

        protected virtual object Insert(T obj)
        {
            throw new NotImplementedException();
        }

        protected virtual object Update(T obj)
        {
            throw new NotImplementedException();
        }

        protected virtual object Delete(T obj)
        {
            throw new NotImplementedException();
        }
    }
}
